/*
  直接更新state的多个方法的对象
*/

import {
  ARTICLES,
  ALL_CATEGORY_GOODS,
  GOODS,
  HOT_GOODS
} from './mutation-types'

export default {
  [ARTICLES] (state, {articles}) {
    if (articles) {
      for (let i = 0; i < articles.length; i++) {
        state.articles.push(articles[i])
      }
    }
  },

  [ALL_CATEGORY_GOODS] (state, {categoryAndGoods}) {
    state.categoryAndGoods = categoryAndGoods
  },

  [GOODS] (state, {goods}) {
    state.goods = goods
  },

  // 热销商品,千万注意参数和state的属性值必须保持一致
  [HOT_GOODS] (state, {hotGoods}) {
    state.hotGoods = hotGoods
  }
}
